package com.example.littleken.recyclerviewtext.Activitys;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.littleken.recyclerviewtext.Adapter.GridAdapter;
import com.example.littleken.recyclerviewtext.R;

public class GridRecyclerViewActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_grid_recycler_view);
        recyclerView = (RecyclerView) findViewById(R.id.rv_grid);
        //设置layoutmanager
        //GridLayoutManager(context,有多少列)
        recyclerView.setLayoutManager(new GridLayoutManager(GridRecyclerViewActivity.this,3));
        //设置适配器
        recyclerView.setAdapter(new GridAdapter(GridRecyclerViewActivity.this));
    }
}
